Skip to content

Add plugin purchase refund system#342

Draft
simonhamp wants to merge 1 commit intomainfrom
refund-plugin-purchases
Draft

Add plugin purchase refund system#342
simonhamp wants to merge 1 commit intomainfrom
refund-plugin-purchases

Conversation

@simonhamp
Copy link
Copy Markdown
Member

Summary

  • Adds a complete refund flow for plugin purchases from the Filament admin panel
  • Issues a full Stripe refund, revokes the license, and cancels/reverses the developer payout — all from a single button
  • Enforces a 14-day refund window; blocks refunds on comped, zero-price, or already-refunded licenses
  • Bundle purchases are refunded all-or-nothing (all sibling licenses sharing the same payment intent)
  • Refunded licenses are excluded from isActive(), the active() scope, and the sales_view

Changes

  • PayoutStatus enum: Added Cancelled case
  • PluginPayout model: Added markAsCancelled(), isCancelled(), cancelled() scope
  • PluginLicense model: Added isRefunded(), isRefundable(), refundedBy() relationship; updated isActive() and active() scope
  • StripeConnectService: Added refundPaymentIntent() and reverseTransfer() methods
  • RefundPluginPurchase action: Orchestrates Stripe refund → DB transaction (license revocation + payout cancellation/reversal)
  • Filament relation managers: Added "Refund" button (danger, with confirmation modal) and "Refunded" column to both Plugin and User license tables
  • Migration: Adds refunded_at, stripe_refund_id, refunded_by to plugin_licenses; updates sales_view to exclude refunded rows
  • Factories: New PluginPayoutFactory with transferred()/cancelled() states; added refunded() state to PluginLicenseFactory

Test plan

  • 11 feature tests covering all paths (tests/Feature/PluginPurchaseRefundTest.php)
  • Manual: Navigate to Plugin → Licenses tab, verify Refund button appears for eligible licenses
  • Manual: Navigate to User → Plugins tab, verify Refund button appears and is hidden for ineligible licenses
  • Manual: Confirm refund modal shows correct amount, user email, and bundle warning when applicable
  • Run full test suite to verify no regressions

🤖 Generated with Claude Code

Adds ability for admins to refund plugin purchases from Filament,
including Stripe refund, license revocation, and payout cancellation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant